The attached patch replaces the current numbers identifying the
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Fri, 21 Apr 2006 10:57:34 +0000 (11:57 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Fri, 21 Apr 2006 10:57:34 +0000 (11:57 +0100)
individual steps of device migration with constants.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
tools/python/xen/xend/XendCheckpoint.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/server/tpmif.py

index f9073a48230f55a92db20838368d5b93f44b95fb..ea3ab2a7d43cf3cab985c3b20aa80f2e7272b3bc 100644 (file)
@@ -21,7 +21,8 @@ import xen.lowlevel.xc
 import balloon
 from XendError import XendError
 from XendLogging import log
-
+from XendDomainInfo import DEV_MIGRATE_STEP1, DEV_MIGRATE_STEP2
+from XendDomainInfo import DEV_MIGRATE_STEP3
 
 SIGNATURE = "LinuxGuestRecord"
 XC_SAVE = "xc_save"
@@ -65,7 +66,7 @@ def save(fd, dominfo, live, dst):
     dominfo.setName('migrating-' + domain_name)
 
     try:
-        dominfo.migrateDevices(live, dst, 1, domain_name)
+        dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP1, domain_name)
 
         write_exact(fd, pack("!i", len(config)),
                     "could not write guest state file: config len")
@@ -87,9 +88,11 @@ def save(fd, dominfo, live, dst):
                 log.debug("Suspending %d ...", dominfo.getDomid())
                 dominfo.shutdown('suspend')
                 dominfo.waitForShutdown()
-                dominfo.migrateDevices(live, dst, 2, domain_name)
+                dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP2,
+                                       domain_name)
                 log.info("Domain %d suspended.", dominfo.getDomid())
-                dominfo.migrateDevices(live, dst, 3, domain_name)
+                dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP3,
+                                       domain_name)
                 tochild.write("done\n")
                 tochild.flush()
                 log.debug('Written done')
index c7c26c1d9c9bba1d3d1065dfbe0a0cf384327c5a..e4d2b31808d25a0b88b8e1a09090870898f5eb41 100644 (file)
@@ -87,6 +87,12 @@ SHUTDOWN_TIMEOUT = 30.0
 
 ZOMBIE_PREFIX = 'Zombie-'
 
+"""Constants for the different stages of ext. device migration """
+DEV_MIGRATE_TEST  = 0
+DEV_MIGRATE_STEP1 = 1
+DEV_MIGRATE_STEP2 = 2
+DEV_MIGRATE_STEP3 = 3
+
 """Minimum time between domain restarts in seconds."""
 MINIMUM_RESTART_TIME = 20
 
@@ -1402,7 +1408,7 @@ class XendDomainInfo:
         @raise: XendError for a device that cannot be migrated
         """
         for (n, c) in self.info['device']:
-            rc = self.migrateDevice(n, c, live, dst, 0)
+            rc = self.migrateDevice(n, c, live, dst, DEV_MIGRATE_TEST)
             if rc != 0:
                 raise XendError("Device of type '%s' refuses migration." % n)
 
index 338bcbffc22efe7e03fcf270923ad2852546b80e..7ab4e50fd0b93be3df6697c43d0860dfd77df594 100644 (file)
@@ -25,6 +25,7 @@ from xen.xend import sxp
 from xen.xend.XendLogging import log
 from xen.xend.XendError import XendError
 from xen.xend import XendRoot
+from xen.xend.XendDomainInfo import DEV_MIGRATE_TEST
 
 from xen.xend.server.DevController import DevController
 
@@ -78,7 +79,7 @@ class TPMifController(DevController):
                 log.info("Request to live-migrate device to %s. step=%d.",
                          dst, step)
 
-                if step == 0:
+                if step == DEV_MIGRATE_TEST:
                     """Assuming for now that everything is ok and migration
                        with the given tool can proceed.
                     """
@@ -90,8 +91,8 @@ class TPMifController(DevController):
                     for line in fd.readlines():
                         mo = re.search('Error', line)
                         if mo:
-                            raise XendError("vtpm: Fatal error in migration step %d." %
-                                            step)
+                            raise XendError("vtpm: Fatal error in migration step %d: %s" %
+                                            (step, line))
                     return 0
             else:
                 log.debug("External migration tool not in configuration.")